﻿@model Dexter.Web.Mvc.ViewModel.Backoffice.ViewsData.PostController.PostEditorViewData
@{
	ViewBag.Title = "Editor";
	Layout = "~/Areas/Admin/Views/Shared/_BackOffice.cshtml";
}

@section header
{
	<link href="@Url.Content( "~/Admin/Resources/Styles/flight-calendar.css" )" rel="stylesheet" type="text/css" />
	<script src="http://cdn.jquerytools.org/1.2.5/form/jquery.tools.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="@Url.Content( "~/Admin/Resources/CkEditor/ckeditor.js" )"></script>
	<script type="text/javascript" src="@Url.Content( "~/Admin/Resources/CkEditor/adapters/jquery.js" )"></script>
	<script type="text/javascript">

		$(document).ready(function () {
			$("#Page_PublishDate").dateinput({
				trigger: true,
				format: 'dd mmmm yyyy',
			});

			$('#publishToday').click(function () {
				$('#Pageost_PublishDate').data("dateinput").today();
				var date = new Date();
				$('#Page_PublishHour').val($.format.date(date,'HH'));
				$('#Page_PublishMinutes').val($.format.date(date,'mm'));
			});

			var config = { toolbar: [
										['Source', '-', 'Save', 'NewPage', 'Preview', '-', 'Templates'],
										['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print', 'SpellChecker', 'Scayt'],
										['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
										'/',
										['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
										['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv'],
										['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
										['BidiLtr', 'BidiRtl'],
										['Link', 'Unlink', 'Anchor'],
										['Image', 'Flash','Video', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Code'],
										'/',
										['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
										['Styles', 'Format', 'Font', 'FontSize'],
										['TextColor', 'BGColor'],
										['Maximize', 'ShowBlocks', '-', 'About']
										]
			};
			config.extraPlugins='video';
			//config.toolbar_Full.push(['Code']);
				

			$('#Post_FormattedBody').ckeditor(config);
		});
	</script>
}


<section class="grid_12">
			@if (!ViewData.ModelState.IsValid) {
				<ul class="message error no-margin">
					@Html.ValidationSummary()
				</ul>	
			}

			<div class="block-border">
				<form method="post" id="simple_form" class="block-content form">
				<h1>Create Post</h1>

				@Html.AntiForgeryToken()
				@Html.Hidden("post.Id", Model.Post.Id)

				<fieldset class="grey-bg required">
					<legend>Required Fields</legend>
					<p>
						<label for="simple-required">Title</label>
						@Html.TextBoxFor(x => x.Post.Title, new { @class = "full-width", placeholder = "Write here the title of the post" })
					</p>
					<p>
						<label for="simple-required">Tags</label>
						@Html.TextBoxFor(x => x.Post.Tags, new { @class = "full-width", placeholder = "Write here tags separeted by comma" })
					</p>

					<p>
						<fieldset class="grey-bg @(!ViewData.ModelState.IsValid && ViewData.ModelState["post.Categories"].Errors != null ? "" : "collapsed")">
						<legend><a href="#">Categories</a></legend>
						<p>
							<label for="simple-required">Categories</label>
							@Html.CategoriesStructure( Model.Categories, "post", Model.Post.Id > 0 ? Model.Post.Categories.Select ( x => x.Id ).ToArray ( ) : null )
						</p>
						</fieldset>
					</p>

					<p>
						@Html.TextAreaFor(x => x.Post.FormattedBody, new { cols = "80", rows = "20"})
					</p>

				</fieldset>

				
				<fieldset class="grey-bg collapsed">
						<legend><a href="#">Optional</a></legend>
							<p>
								<label for="simple-required">Publish Date</label>
								<span class="input-type-text margin-right">
									@Html.EditorFor(x => x.Post.PublishDate)
									<img height="16" width="16" src="@Url.Content( "~/admin/Resources/images/Icons/Fugue/calendar-month.png" )" alt="calendar" />
									@Html.DropDownListFor(x => x.Post.PublishHour, new SelectList(Model.Hours, Model.Post.PublishHour))
									@Html.DropDownListFor(x => x.Post.PublishMinutes, new SelectList(Model.Minutes, Model.Post.PublishMinutes))
								</span>
								<button class="grey" type="button" id="publishToday">Today</button>
								&nbsp;
								<label for="table-display" style="display:inline">Publish</label>
								@Html.CheckBoxFor( x => x.Post.Publish, new { @class = "mini-switch"} )
								
								<label for="table-display" style="display:inline">Break Post</label>
								@Html.CheckBoxFor( x => x.Post.BreakOnAggregate, new { @class = "mini-switch"} )
								&nbsp;
								<label for="table-display" style="display:inline">Enable Comments</label>
								@Html.CheckBoxFor( x => x.Post.CommentEnabled, new { @class = "mini-switch"} )
							</p>
							
							<p>
								<label for="simple-required">Slug</label>
								@Html.TextBoxFor(x => x.Post.Slug, new { @class = "full-width", placeholder = "Write the slug of the post" })
							</p>

							<p>
								<label for="simple-required">Abstract</label>
								@Html.TextBoxFor(x => x.Post.Abstract, new { @class = "full-width", placeholder = "Write the abstract of the post" })
							</p>
					</fieldset>


					<p class="input-with-button">
						<button type="submit">Save</button>
					</p>

				</form>
			</div>
		</section>
